home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_6.lha / 7_6 / 7_6_getn.c < prev    next >
Text File  |  1993-08-08  |  573b  |  40 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / Get the next entry from a list,
  6. / removing it afterwards.
  7. / curr is left alone.
  8. nt dlist::getnext(ent &a)
  9.  
  10.    if (!last)
  11. return 0;
  12.  
  13.    // choose the link to remove
  14.    dlink *f;
  15.    if (curr)
  16.        if (curr == last)
  17.     {
  18.     curr = 0;
  19.     return 0;
  20.     }
  21.  
  22. else
  23.     f = curr->next;
  24.  
  25.    else
  26. f = last->next;
  27.  
  28.    a = f->e;
  29.  
  30.    // remove f from the list
  31.    if (f == last)
  32. last = 0;
  33.  
  34.    else
  35. f->remove();
  36.  
  37.    delete f;
  38.    return 1;
  39.  
  40.